﻿package frEngine.animateControler.particleControler.animate
{
    import __AS3__.vec.*;
    import flash.geom.*;
    import frEngine.animateControler.particleControler.*;

    public class UseSimpleHarmonicVibration extends Object implements IParticleAnimate
    {
        private var shvDirectionX:Number;
        private var shvDirectionY:Number;
        private var shvDirectionZ:Number;
        private var shvValueX:Number;
        private var shvValueY:Number;
        private var shvValueZ:Number;
        private var shvValueW:Number;
        public static const instance:UseSimpleHarmonicVibration = new UseSimpleHarmonicVibration;

        public function UseSimpleHarmonicVibration()
        {
            return;
        }// end function

        public function get objClass() : Class
        {
            return UseSimpleHarmonicVibration;
        }// end function

        public function canOpen(param1:ParticleParams) : Boolean
        {
            return param1.useSimpleHarmonicVibration;
        }// end function

        public function update(param1:ParticleStatus) : void
        {
            var _loc_4:ParticleItem = null;
            var _loc_5:Vector3D = null;
            var _loc_7:Number = NaN;
            var _loc_8:Number = NaN;
            var _loc_2:* = param1.particleList;
            var _loc_3:* = _loc_2.length;
            var _loc_6:int = 0;
            while (_loc_6 < _loc_3)
            {
                
                _loc_4 = _loc_2[_loc_6];
                if (_loc_4.visible && _loc_4.toUpdate)
                {
                    _loc_5 = _loc_4.resultPos;
                    _loc_7 = this.shvValueW * _loc_4.randomValue + this.shvValueZ + _loc_4.curFrame;
                    _loc_7 = _loc_7 / this.shvValueX;
                    _loc_8 = Math.sin(_loc_7) * this.shvValueY;
                    _loc_5.x = _loc_5.x + this.shvDirectionX * _loc_8;
                    _loc_5.y = _loc_5.y + this.shvDirectionY * _loc_8;
                    _loc_5.z = _loc_5.z + this.shvDirectionZ * _loc_8;
                }
                _loc_6++;
            }
            return;
        }// end function

        public function init(param1:ParticleStatus, param2:ParticleParams) : void
        {
            var _loc_3:* = param2.shvDirection;
            var _loc_4:* = param2.shvValue;
            this.shvDirectionX = _loc_3.x;
            this.shvDirectionY = _loc_3.y;
            this.shvDirectionZ = _loc_3.z;
            this.shvValueX = _loc_4.x;
            this.shvValueY = _loc_4.y;
            this.shvValueZ = _loc_4.z;
            this.shvValueW = _loc_4.w;
            return;
        }// end function

    }
}
